﻿// See https://aka.ms/new-console-template for more information

using Akka.Actor;
using Akka.Configuration;
using Dapper.Sharding.CAP;
using RestSharp;

var configIni = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
var config = ConfigurationFactory.ParseString(configIni);
var system = ActorSystem.Create("serverSys", config);

var serverCap = new ServerCap(system, "server");

var res = await serverCap.ExecuteAsync((token, actorPath) =>
{
    Console.WriteLine(token);
    Console.WriteLine(actorPath);
    
    //微服务1
    var client = new RestClient("http://localhost:9000");
    var req = new RestRequest("/home/index");
    req.AddQueryParameter("token", token);
    req.AddQueryParameter("actorPath", actorPath);
    var task1 = client.ExecuteAsync(req);

    //微服务2
    var client2 = new RestClient("http://localhost:9001");
    var req2 = new RestRequest("/home/index");
    req2.AddQueryParameter("token", token);
    req2.AddQueryParameter("actorPath", actorPath);
    var task2 = client2.ExecuteAsync(req2);
    return new Task[] { task1, task2 };
});
Console.WriteLine(res.Success);

Console.WriteLine("Hello, World!");
